package com.somobile.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.somobile.results.beans.QuestionResults;
import com.somobile.services.IQuestionService;



@Controller
public class QuestionController 
{
	
	@Autowired
	IQuestionService questionService;
	
	@RequestMapping("/questions")
	public ModelAndView showAllQuestions()
	{

		QuestionResults questionres = questionService.getActiveQuetions();
		System.out.println("All Questions");
		return (new ModelAndView("questions")).addObject("questionres",questionres);
	}
	
	
	@RequestMapping("/questions/{questionId}")
	public ModelAndView showQuestion(@PathVariable String questionId)
	{	
		return (new ModelAndView("questiondetail")).addObject("question",questionService.getQuestion(Long.parseLong(questionId)));		
	}
/*	
	@RequestMapping("/questions/{questionId}")
	public ModelAndView showQuestion(@PathVariable String questionId)
	{
	}
		*/

}
